package com.example.administrator.yuejian_15.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;


import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.adapter.PxAdapter;
import com.example.administrator.yuejian_15.bean.PxBean;
import com.example.administrator.yuejian_15.listener.ListListener;
import com.example.administrator.yuejian_15.model.PxJjModel;

import java.util.List;

public class PxJjActivity extends BaseActivity implements View.OnClickListener{
    ImageView jjpx_fh;
    RecyclerView rv_jjpxlist;
    List<PxBean> items;
    @Override
    void initView() {
        setLayout_file(R.layout.activity_px_jj);

        jjpx_fh=(ImageView)findViewById(R.id.jjpx_fh);
        rv_jjpxlist=(RecyclerView)findViewById(R.id.rv_jjpxlist);
        PxJjModel pxJjModel=new PxJjModel();
        pxJjModel.getJjList(pxBeanListListener);


    }

    @Override
    void initEvent() {
        jjpx_fh.setOnClickListener(this);

    }

    @Override
    void initDate() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.jjpx_fh:
                finish();
                break;
        }
    }

    ListListener<PxBean> pxBeanListListener=new ListListener<PxBean>() {
        @Override
        public void onResponse(List<PxBean> list) {
            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(PxJjActivity.this);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rv_jjpxlist.setLayoutManager(linearLayoutManager);
            items=list;
            PxAdapter pxAdapter=new PxAdapter(PxJjActivity.this,items,R.layout.item);
            rv_jjpxlist.setAdapter(pxAdapter);
            rv_jjpxlist.setItemAnimator(new DefaultItemAnimator());
        }

        @Override
        public void onFail(String msg) {

        }
    };


}
